import '../bridge/native_channel_bridge.dart';

enum AppEnvTypeInterface { testEnv, preEnv, prodEnv }

class EnvType {
  String downLoadUri;
  // kai earn Uri  理财
  String kaiEarnUri;
  // kaiPay Uri  充值平台
  String kaiPayUri;
  // integralRuleUri Uri  积分平台
  String integralRuleUri;

  EnvType(
      {required this.downLoadUri,
      required this.integralRuleUri,
      required this.kaiEarnUri,
      required this.kaiPayUri});
}

class EnvUtil {
  // ------------------- 测试环境 ---------------------------
  static EnvType testEnv = EnvType(
    downLoadUri: 'http://test-event.kaiaction.com',
    kaiEarnUri: 'http://test-earn.ai-chat.ltd',
    kaiPayUri: 'http://test-pay.kai.com',
    integralRuleUri: 'http://test-event.kaiaction.com',
  );
  // ------------------- 预发布环境 ---------------------------
  static EnvType preEnv = EnvType(
    downLoadUri: 'http://eks-activity.ai-chat.ltd',
    kaiEarnUri: 'http://eks-finance.ai-chat.ltd',
    kaiPayUri: 'http://eks-kaipayplatform.ai-chat.ltd',
    integralRuleUri: 'http://eks-activity.ai-chat.ltd',
  );

  // ------------------- 正式环境 ---------------------------
  static EnvType prodEnv = EnvType(
    downLoadUri: 'https://event.kaiaction.com',
    kaiEarnUri: 'https://earn.kai.com',
    kaiPayUri: 'https://pay.kai.com',
    integralRuleUri: 'https://event.kaiaction.com',
  );

  static EnvType getEnvConfig() {
    final String appEnvType =
        NativeChannelBridge.instance.appCommMsg!.appEnvType.toString();
    if (AppEnvTypeInterface.testEnv.index.toString() == appEnvType) {
      return testEnv;
    }
    if (AppEnvTypeInterface.preEnv.index.toString() == appEnvType) {
      return preEnv;
    }
    return prodEnv;
  }
}
